package com.jzy.bxb.manage.service;

import java.util.List;
import java.util.stream.Collectors;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jzy.bxb.manage.core.service.MongoBaseService;
import com.jzy.bxb.model.mongo.dao.ConfigCityDao;
import com.jzy.bxb.model.mongo.entity.config.ConfigCity;

/**
 * 小区
 * 
 * @author JiangZhiYong QQ:359135103
 */
@Service
public class CommunityService extends MongoBaseService<ConfigCity, String> {

	@Autowired
	private ConfigCityDao configCityDao;

	@PostConstruct
	private void init() {
		ConfigCityDao.setConfigCityDao(configCityDao);
	}

	public ConfigCityDao getConfigCityDao() {
		return configCityDao;
	}

	public void setConfigCityDao(ConfigCityDao configCityDao) {
		this.configCityDao = configCityDao;
		setBaseDao(configCityDao);
	}

	public List<String> getCityNames() {
		List<String> list = configCityDao.createQuery().asList().stream().map(ConfigCity::getName)
				.collect(Collectors.toList());
		return list;
	}

	public ConfigCity getConfigCity(String city) {
		return ConfigCityDao.getConfigCity(city);
	}

}
